/*
 * libkysdk-system's Library
 *
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Authors: Yunhe Liu <liuyunhe@kylinos.cn>
 *
 */

#ifndef KYLINOCR_H
#define KYLINOCR_H

#include <iostream>
#include <string>
#include <vector>

// namespace kdk {

//     class kdkOCR {
//     public:

//         std::vector<std::vector<std::vector<int>>> getRect(const std::string &imagePath);

//         std::vector<std::string> getCls(const std::string &imagePath, int nums);



//     };
// }

namespace kdk
{
    /**
     * @brief ocr的识别结果
     *
     */
    struct TOcrResult
    {
        std::string imagePath;
        volatile bool hasGotRect;
        std::vector<std::vector<std::vector<int>>> textRects;
        std::vector<std::string> texts;

        TOcrResult();

        void reset();

        bool isNewPath(const std::string &strImagePath) const;
    };

    class kdkOCR
    {
    protected:
        TOcrResult objOcrRet;

    public:
        kdkOCR();
        std::vector<std::vector<std::vector<int>>> getRect(const std::string &imagePath);
        std::vector<std::string> getCls(const std::string &imagePath, int nums);

    protected:
        void handleImage(const std::string &imagePath);
    };
}

extern "C" {
        std::vector<std::vector<std::vector<int>>> getRect(const std::string &imagePath) {
            kdk::kdkOCR obj;
            return obj.getRect(imagePath);
        }

        std::vector<std::string> getCls(const std::string &imagePath, int nums) {
                            kdk::kdkOCR obj;
                return obj.getCls(imagePath, nums);
        }
}

#endif //KYLINOCR_H
